import React, { Component } from "react";
import { Route, Switch, Redirect } from "react-router-dom";
import NavLinkBar from "../navlink";
import Read from "../../container/read";
import Discover from "../../container/discover";
import Mine from "../../container/mine";

import './dashboard.less'

class Dashboard extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }
  render() {
    const { pathname } = this.props.location;
    const navList = [
      {
        path: "/read",
        text: "读书",
        icon: "read",
        component: Read
      },
      {
        path: "/discover",
        text: "发现",
        icon: "discover",
        component: Discover
      },
      {
        path: "/mine",
        text: "我的",
        icon: "mine",
        component: Mine
      }
    ];
    const page = navList.find(v => v.path === pathname);
    return page ? (
      <div className="fullPage">
        <Route path={page.path} key={page.path} component={page.component} />
        <NavLinkBar data={navList} />
      </div>
    ) : (
      <Redirect to="/read" />
    );
  }
}
export default Dashboard;
